package com.school.gift.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.school.gift.domain.Goods;
import com.school.gift.mapper.GoodsMapper;
import com.school.gift.model.GoodsModel;
import com.school.gift.service.GoodsService;
import zhibi.common.support.base.Page;
import zhibi.common.support.base.service.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import zhibi.common.support.mybatis.example.Example;

/**
* The class create by 执笔 on generate.
*/
@Service
@Transactional
public class GoodsServiceImpl extends BaseServiceImpl<Goods> implements GoodsService {

    @Autowired
    public GoodsServiceImpl(GoodsMapper mapper) {
        super(mapper);
        this.goodsMapper = mapper;
    }
    private GoodsMapper goodsMapper;

    @Override
    public PageInfo<GoodsModel> selectModel(Example example, Page page) {
        if(null != page){
            PageHelper.startPage(page.getPageNum(),page.getPageSize());
        }
        return new PageInfo<>(goodsMapper.selectModel(example));
    }

    @Override
    public GoodsModel selectModelById(Integer goodsId) {
        return goodsMapper.selectModelById(goodsId);
    }
}